package com.yan.jackson;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.json.JsonMapper;

import java.io.File;
import java.io.IOException;
import java.lang.reflect.Type;
import java.util.List;

/**
 * @author taoge
 * @Date 2024/8/13 16:22
 * @Description
 */
public class JacksonDemo1 {
    public static void main(String[] args) throws IOException {
        String listStu = "[{\"age\":18,\"birthday\":0,\"name\":\"hpy\"},{\"age\":19,\"birthday\":110,\"name\":\"cqp\"},{\"age\":20,\"birthday\":11110,\"name\":\"wl\"}]";
        JsonMapper mapper = new JsonMapper();
        mapper.writeValue(new File("day18_code/src/com/yan/jackson/jackson.json") , listStu);

       /* List<Student> students = mapper.readValue(listStu, new TypeReference<List<Student>>() {});
        for (Student student : students) {
            System.out.println(student);
        }*/
    }
}
